home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / beebe / c / old / dvil3p < prev   
Encoding:
Text File  |  1990-12-05  |  10.9 KB  |  341 lines

  1. /* -*-C-*- dvil3p.c */
  2. /*-->dvil3p*/
  3. /**********************************************************************/
  4. /******************************* dvil3p *******************************/
  5. /**********************************************************************/
  6.  
  7. #include "dvihead.h"
  8.  
  9. /**********************************************************************/
  10. /************************  Device Definitions  ************************/
  11. /**********************************************************************/
  12.  
  13. /* All output-device-specific definitions go here.  This section must
  14. be changed when modifying a dvi driver for use on a new device */
  15.  
  16. #undef DECLN03PLUS
  17. #define  DECLN03PLUS 1                  /* conditional compilation flag */
  18.  
  19. #undef HIRES                            /* this is 150 dpi version */
  20. #define  HIRES            1             /* define for 300 dpi version */
  21.  
  22. #define VERSION_NO      "2.10"          /* DVI driver version number */
  23.  
  24. #if    HIRES
  25. #define  DEVICE_ID      "Digital LN03-PLUS 300 dpi laser printer"
  26.                                         /* this string is printed at runtime */
  27. #define  XDPI           300             /* horizontal dots/inch */
  28. #define  YDPI           300             /* vertical dots/inch */
  29. #else
  30. #define  DEVICE_ID      "Digital LN03-PLUS 150 dpi laser printer"
  31.                                         /* this string is printed at runtime */
  32. #define  XDPI           150             /* horizontal dots/inch */
  33. #define  YDPI           150             /* vertical dots/inch */
  34. #endif
  35.  
  36. #define OUTFILE_EXT     "l3p"
  37.  
  38. #define  BYTE_SIZE        7             /* output file byte size */
  39.  
  40. #undef STDRES
  41. #define STDRES  1               /* 0 for low-resolution devices */
  42.  
  43. #define  V6SIZE         XSIZE
  44. #define  XPSIZE         8               /* horizontal paper size in inches */
  45. #define  XSIZE          (((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\
  46.                                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))
  47.                                         /* number of horizontal dots; */
  48.                                         /* MUST BE multiple of */
  49.                                         /* 2*HOST_WORD_SIZE */
  50. #define  XWORDS         ((XSIZE + HOST_WORD_SIZE - 1)/HOST_WORD_SIZE)
  51.                                         /* number of words in rows  */
  52.                                         /* of bitmap array */
  53. #define  YPSIZE         11              /* vertical paper size in inches */
  54. #define  YSIZE          (YDPI*YPSIZE)   /* number of vertical dots */
  55.  
  56. /* The printer bit map (must have a multiple of 6 rows) */
  57.  
  58. #define XBIT ((1+2*XWORDS)/2)
  59. #define YBIT (((YSIZE+5)/6)*6)
  60.  
  61. #if    (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD)
  62. #undef SEGMEM
  63. #define SEGMEM 1 /* ( ((long)XBIT * (long)YBIT) > 65536L ) */
  64. #endif
  65.  
  66. #include "bitmap.h"
  67.  
  68.  
  69. #include "main.h"
  70. #include "abortrun.h"
  71. #include "actfact.h"
  72. #include "alldone.h"
  73. #include "chargf.h"
  74. #include "charpk.h"
  75. #include "charpxl.h"
  76. #include "clrbmap.h"
  77. #include "clrrow.h"
  78. #include "dbgopen.h"
  79.  
  80. /*-->devinit*/
  81. /**********************************************************************/
  82. /****************************** devinit *******************************/
  83. /**********************************************************************/
  84.  
  85. void
  86. devinit(argc,argv)              /* initialize device */
  87. int argc;
  88. char *argv[];
  89. {
  90.     (void)getbmap();
  91.     if (runlengthcode && !quiet)
  92.     {
  93.         (void)fprintf(stderr,"[Run-length encoding of output file]");
  94.         NEWLINE(stderr);
  95.     }
  96. }
  97.  
  98. /*-->devterm*/
  99. /**********************************************************************/
  100. /****************************** devterm *******************************/
  101. /**********************************************************************/
  102.  
  103. void
  104. devterm()                       /* terminate device */
  105. {
  106. }
  107.  
  108. #include "dispchar.h"
  109. #include "dvifile.h"
  110. #include "dviinit.h"
  111. #include "dviterm.h"
  112. #include "f20open.h"
  113. #include "fatal.h"
  114. #include "fillrect.h"
  115. #include "findpost.h"
  116. #include "fixpos.h"
  117. #include "fontfile.h"
  118. #include "fontsub.h"
  119. #include "getbmap.h"
  120. #include "getbytes.h"
  121. #include "getfntdf.h"
  122. #include "getpgtab.h"
  123. #include "inch.h"
  124. #include "initglob.h"
  125. #include "loadchar.h"
  126. #include "movedown.h"
  127. #include "moveover.h"
  128. #include "moveto.h"
  129. #include "nosignex.h"
  130. #include "openfont.h"
  131. #include "option.h"
  132.  
  133. /*-->outline*/
  134. /**********************************************************************/
  135. /****************************** outline *******************************/
  136. /**********************************************************************/
  137.  
  138. void
  139. outline(pline)
  140. char *pline;                            /* pointer to raster line */
  141. {
  142.    /* On return, the caller must output the character that selects the
  143.       spacing to the next line */
  144.  
  145.     register INT16 left;
  146.     register char *a,*b,*c;
  147.     INT16 len;
  148.  
  149.     for ((left = V6SIZE, c = pline + V6SIZE - 1);
  150.         (*c == '\077') && (left > 1);
  151.         (--left,--c))                   /* trim white space but leave */
  152.         ;                               /* at least 1 character in line */
  153.  
  154.     /*******************************************************************
  155.     We search for runs as follows.  "b" marks the beginning of unwritten
  156.     data, and "a" anchors the beginning of a run which continues to just
  157.     before "c".   The  run length  is  "c"-"a".  Since  the  run  length
  158.     encoding carries a penalty of additional output equal to the  length
  159.     of the  run  length  prefix (!<number>), short runs are not encoded.
  160.  
  161.     If a long  enough run  is found,  then the  string "b"  .. "a"-1  is
  162.     output since its length is now  known, followed by the run  encoding
  163.     for the character at "a".  Then "a" and "b" are advanced to "c", and
  164.     the scan continues.
  165.  
  166.     If the  run  beginning at  "a"  is too  short,  then "a"  is  simply
  167.     advanced.
  168.  
  169.     We do not store a termination marker, but instead  keep  a  counter,
  170.     "left", which is  decremented to  0 when the  end of  the string  is
  171.     reached.
  172.  
  173.     ?????????????xxxxxxxxxxxxxxxx????????????????????
  174.     ^            ^               ^
  175.     |            |               |
  176.     b            a               c
  177.  
  178.                  <-----run------>
  179.     *******************************************************************/
  180.  
  181.     if (runlengthcode && (left > 3))
  182.     {
  183.         for (a = b = pline; (left > 0); --left)
  184.         {
  185.             for (c = a; (*a == *++c) && left; --left)
  186.                 ;                           /* advance over run */
  187.             len = (INT16)(c-a);             /* "c" points past run */
  188.             if (len > 3)                    /* output long run */
  189.             {
  190.                 if (a > b)                  /* output previous string */
  191.                 {
  192.                     for ( ; b < a; b++)
  193.                         OUTC(*b);
  194.                 }
  195.                 OUTF2("!%d%c",len,*a);
  196.                 a = b = c;
  197.             }
  198.             else                            /* ignore short run */
  199.             {
  200.                 ++a;
  201.                 left += len - 1;
  202.             }
  203.         }
  204.         if (a > b)          /* output remaining string */
  205.         {
  206.             for ( ; b < a; b++)
  207.                 OUTC(*b);
  208.         }
  209.     }
  210.     else                                /* no runlength coding */
  211.     {
  212.        for (c = pline; left; --left, c++)
  213.            OUTC(*c);
  214.     }
  215. }
  216.  
  217. #include "outrow.h"
  218.  
  219. /*-->prtbmap*/
  220. /**********************************************************************/
  221. /****************************** prtbmap *******************************/
  222. /**********************************************************************/
  223.  
  224. void
  225. prtbmap()
  226. {
  227.     register char *c;                   /* pointer into v6[] */
  228.     UNSIGN32 *p;                        /* pointer into bitmap[][] */
  229.     register UNSIGN32 mask;             /* mask for single bit selection */
  230.     INT16 i,j,k,ybottom,ytop;
  231.     char v6[V6SIZE];                    /* vertical 6-bit raster encodings */
  232.  
  233. #if    SEGMEM
  234.     UNSIGN32* q[6];                     /* pointers to 6 raster lines */
  235. #define Q(n) q[n]                       /* use precomputed pointers */
  236. #else /* NOT SEGMEM */
  237. #define Q(n) (p - (n)*XBIT)             /* compute pointers on the fly */
  238. #endif /* SEGMEM */
  239.  
  240.     ytop = YSIZE-1;
  241.  
  242.     k = -1;         /* find bottom non-zero raster */
  243.     for (j = 0; (j < ytop) && (k < 0); ++j) /* loop over raster lines */
  244.     {
  245.  
  246. #if    IBM_PC_MICROSOFT
  247.         for (k = XBIT - 1; ((k >= 0) && (*BITMAP(j,k) == 0)); --k)
  248.             ;                           /* trim white space */
  249. #else
  250.         p = BITMAP(j,XBIT-1);
  251.         for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
  252.             --p;                        /* trim white space */
  253. #endif
  254.  
  255.     }
  256.     ybottom = MAX(0,6*((j-1)/6));       /* need 6n raster lines */
  257.  
  258. #if    HIRES
  259.     /* <CR><ESC>[7 I<ESC>P0;0;1q"1;1 for 300 dpi spacing */
  260.     OUTS("\015\033[7 I\033P0;0;1q\0421;1");
  261. #else
  262.     /* <CR><ESC>[7 I<ESC>P0;0;2q"1;1 for 150 dpi spacing */
  263.     OUTS("\015\033[7 I\033P0;0;2q\0421;1");
  264. #endif
  265.  
  266.     for (j = ytop; (j >= ybottom) ; j -= 6)    /* loop over raster lines */
  267.                                                /* in groups of 6 */
  268.     {
  269. #if    SEGMEM
  270. #else
  271.         p = BITMAP(j,0);        /* the j-th raster line */
  272. #endif
  273.  
  274.         c = &v6[0];             /* vertical 6-bit encodings */
  275.         for (i = 0; i < XBIT; (++p,++i))        /* loop over raster words */
  276.         {
  277.             /* PCC-20 compiled (1 << (HOST_WORD_SIZE-1)) to 0, so do it the
  278.                hard way, arghh... */
  279.             mask = 1;
  280.             mask <<= (HOST_WORD_SIZE-1);        /* to select leftmost bit */
  281.  
  282. #if    SEGMEM
  283.             for (k = 0; k < 6; ++k)     /* compute pointers to 6 rasters */
  284.                 q[k] = BITMAP(j-k,i);
  285. #endif
  286.  
  287.             for (k = 0; k < HOST_WORD_SIZE; (++c,++k))/* loop over word bits */
  288.             {
  289.                 /* examine bits in 6 adjacent rows and build 6-bit */
  290.                 /* character value */
  291.                 *c = '\0';              /* clear character template */
  292.                 if (*Q(0) & mask)
  293.                     *c |= '\001';
  294.                 if (*Q(1) & mask)
  295.                     *c |= '\002';
  296.                 if (*Q(2) & mask)
  297.                     *c |= '\004';
  298.                 if (*Q(3) & mask)
  299.                     *c |= '\010';
  300.                 if (*Q(4) & mask)
  301.                     *c |= '\020';
  302.                 if (*Q(5) & mask)
  303.                     *c |= '\040';
  304.                 mask >>= 1;             /* move masking bit right 1 position */
  305.                 *c += '\077';           /* bias 6-bit value by 63 */
  306.             }
  307.         };
  308.         outline(&v6[0]);
  309.         OUTS("-\n");
  310.     }
  311.     /* Terminate the graphics image */
  312.     /* <ESC>\<FF>
  313.     */
  314.     OUTS("\033\\\f");
  315.  
  316. }
  317.  
  318. #include "prtpage.h"
  319. #include "readfont.h"
  320. #include "readgf.h"
  321. #include "readpk.h"
  322. #include "readpost.h"
  323. #include "readpxl.h"
  324. #include "reldfont.h"
  325. #include "rulepxl.h"
  326. #include "setchar.h"
  327. #include "setfntnm.h"
  328. #include "setrule.h"
  329. #include "signex.h"
  330. #include "skgfspec.h"
  331. #include "skipfont.h"
  332. #include "skpkspec.h"
  333. #include "special.h"
  334. #include "strchr.h"
  335. #include "strcm2.h"
  336. #include "strid2.h"
  337. #include "strrchr.h"
  338. #include "tctos.h"
  339. #include "usage.h"
  340. #include "warning.h"
  341.